//
//  UIColor+CustomColors.m
//

#import "UIColor+CustomColors.h"

@implementation UIColor (CustomColors)

+ (UIColor*)customTextGrayBlackColor
{
    return [self customTextGrayColor];//[self colorWithRed:94 green:94 blue:94];
}

+ (UIColor*)customTextGrayColor
{
    return [self colorWithRed:166 green:166 blue:166];
}

+ (UIColor*)customRedColor
{
    return [self colorWithRed:212 green:60 blue:51];
    //   return [self colorWithRed:231 green:76 blue:60];
}

+ (UIColor*)customYellowColor
{
    return [self colorWithRed:241 green:138 blue:16];
}

+ (UIColor*)customGreenColor
{
    return [self colorWithRed:57 green:200 blue:145];
}

+ (UIColor*)customBlueColor
{
    return [self colorWithRed:52 green:152 blue:219];
}

+ (UIColor*)customBackgroudColor
{
    return [self colorWithRed:241 green:241 blue:241];
}

+ (UIColor*)customMaintenanceTypeColor
{
    return [self colorWithRed:256 green:153 blue:0];
}

+ (UIColor*)customLineColor{
    return [UIColor colorWithHex:@"D9D9D9"];
}
#pragma mark - Private class methods

+ (UIColor*)colorWithRed:(NSUInteger)red
                   green:(NSUInteger)green
                    blue:(NSUInteger)blue
{
    return [UIColor colorWithRed:(float)(red / 255.f)
                           green:(float)(green / 255.f)
                            blue:(float)(blue / 255.f)
                           alpha:1.f];
}

+ (UIColor*)colorWithHex:(NSString*)string
{
    NSString* cleanString = [string stringByReplacingOccurrencesOfString:@"#" withString:@""];
    if ([cleanString length] == 3) {
        cleanString = [NSString stringWithFormat:@"%@%@%@%@%@%@",
                                [cleanString substringWithRange:NSMakeRange(0, 1)], [cleanString substringWithRange:NSMakeRange(0, 1)],
                                [cleanString substringWithRange:NSMakeRange(1, 1)], [cleanString substringWithRange:NSMakeRange(1, 1)],
                                [cleanString substringWithRange:NSMakeRange(2, 1)], [cleanString substringWithRange:NSMakeRange(2, 1)]];
    }
    if ([cleanString length] == 6) {
        cleanString = [cleanString stringByAppendingString:@"ff"];
    }

    unsigned int baseValue;
    [[NSScanner scannerWithString:cleanString] scanHexInt:&baseValue];

    float red = ((baseValue >> 24) & 0xFF) / 255.0f;
    float green = ((baseValue >> 16) & 0xFF) / 255.0f;
    float blue = ((baseValue >> 8) & 0xFF) / 255.0f;

    return [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}
@end
